<?php
$id = $_POST["id"];
$yqrid = $_POST['yqrid'];
$name = $_POST['name'];
$api_type = $_POST['api_type'];
$productType = $_POST['productType'];
$goodsCode = $_POST['goodsCode'];
$sku = $_POST['sku'];
$se_num = $_POST['se_num'];
$downtel = $_POST['downtel'];
$jieshao = $_POST['jieshao'];
$yys = $_POST['yys'];
$ltime = $_POST['ltime'];
$zhutu = $_POST['zhutu'];
$link = $_POST['link'];
$price = $_POST['price'];
$proxy_price = $_POST['proxy_price'];
$notes = $_POST['notes'];
$xuanhao = $_POST['xuanhao'];
$baoyou = $_POST['baoyou'];
$gsd = $_POST['gsd'];
$other = $_POST['other'];

$haokaid = ''; // 初始化$haokaid变量

if ($api_type === 'yqrapi') {
  $haokaid = $yqrid;
} elseif ($api_type === 'hnhklt') {
  $haokaid = $productType;
}elseif ($api_type === 'haokeyun') {
  $haokaid = $goodsCode;
}elseif ($api_type === 'gantanhao') {
  $haokaid = $sku;
}

include_once("../../untils/conn.php");
if ($con) {
    mysqli_query($con, "set names utf8");
    $data = $con->query("UPDATE list SET name='" . $name . "',jieshao='" . $jieshao . "',haokaid='" . $haokaid . "',yys='" . $yys . "',ltime='" . $ltime . "',zhutu='" . $zhutu . "' ,link='" . $link . "',price='" . $price . "',proxy_price='" . $proxy_price . "',notes='" . $notes . "',xuanhao='" . $xuanhao . "',other='" . $other . "',baoyou='" . $baoyou . "',gsd='" . $gsd . "', api_type='" . $api_type . "', se_num='" . $se_num . "' ,downtel='" . $downtel . "' WHERE id=" . $id);
    if ($data > 0) {
        echo "<script>alert('更新成功');window.location.href='../list.php'</script> ";
    } else {
        echo ("<script>alert('更新失败');window.location.replace(document.referrer)</script>");
        // echo "Error updating record: " . $con->error;
    }
}
$con->close();
